package com.core.image.core;

/**
 * describe:
 *
 * @author 库琦
 * @date 2020/01/30
 */
public class BytePriorityNode<Item> {
    public byte priority;
    public Item item;
    public BytePriorityNode<Item> next;
    public BytePriorityNode(Item item){
        this.item = item;
    }

    /**
     * 按优先级追加到当前链表中。
     * @param node
     */
    public void appendWithPriority(BytePriorityNode<Item> node){
        if (next == null){
            next = node;
        }else {
            BytePriorityNode<Item> after = this.next;
            if (after.priority < node.priority){
                this.next = node;
                node.next = after;
            }else {
                after.appendWithPriority(node);
            }
        }
    }
}
